package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.FloorDto;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.ContractVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目管理")
public class NursingProjectController extends BaseController{

    @Autowired
    private NursingProjectService nursingProjectService;

    @ApiOperation(value = "分页查询护理项数据")
    @GetMapping
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "护理项名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态", required = false, dataType = "int", paramType = "query")
    })
    public ResponseResult<PageResponse<NursingProjectVo>> selectByPage(Integer pageNum,
                                                                       Integer pageSize,
                                                                       String name,
                                                                       Integer status){
        PageResponse<NursingProjectVo> pageInfo = nursingProjectService.selectByPage(pageNum, pageSize, name, status);
        return success(pageInfo);
    }



    @PostMapping
    @ApiOperation(value = "添加护理项")
    public ResponseResult addNursingProject(
            @ApiParam(value = "护理项目数据传输对象", required = true)
            @RequestBody NursingProjectDto nursingProjectDto) {
        nursingProjectService.addFloor(nursingProjectDto);
        return success();
    }

    @GetMapping("/{id}")
    public ResponseResult<NursingProjectVo> getById(
            @PathVariable("id") Long id) {
        NursingProjectVo vo = nursingProjectService.getById(id);
        return success(vo);
    }

    @PutMapping
    @ApiOperation("修改护理项目")
    public ResponseResult update(@RequestBody NursingProjectDto nursingProjectDTO) {
        nursingProjectService.update(nursingProjectDTO);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用/禁用护理项目")
    public ResponseResult disable(@PathVariable("id") Long id,
                                  @PathVariable("status") Integer status) {
        nursingProjectService.disable(id,status);
        return success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除护理项目")
    public ResponseResult<NursingProjectVo> deleteById(
            @PathVariable("id") Long id) {
        nursingProjectService.deleteById(id);
        return success();
    }

}
